package com.stsolutions.budgetcontroller.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.util.Log;

public class FormatDate {
	private static final String APP_DATE_FORMAT = "dd/MM/yyyy";
	private static DateFormat df = new SimpleDateFormat(APP_DATE_FORMAT);

	public static Date getDateObject(String date) {
		Log.i(FormatDate.class.getName(), "this is the message parsing date: "
				+ date);
		Date result = null;
		try {
			result = df.parse(date);
		} catch (ParseException e) {
			Log.e(FormatDate.class.getName(), "error when parsing", e);
			result = new Date();
		}
		Log.i(FormatDate.class.getName(), "Date Parsed : " + result);
		return result;
	}

	public static String formatDate(Date date) {
		return df.format(date);
	}

}
